﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace University.Workshop.Presenters.OtbData.Read
{
    public class PresenterReadOtbData
    {
        IReadBasicOtbDataView viewReadBasic;
        IReadPrincipalView view;
        Model.OtbData otbData = new Model.OtbData() { Person = new Model.Person() };

        public PresenterReadOtbData(IReadPrincipalView view, Model.OtbData otb)
        {
            this.view = view;
            otbData = otb;
        }

        public void GoStepTwo()
        {
            view.CallSecondPage();
            ProcedureAfterCall();
        }

        public void GoBackPage()
        {
            viewReadBasic.GoBackPage();
        }

        public void GoNextPage()
        {
            viewReadBasic.GoNextPage();
        }
        public void GoStepOne()
        {
            view.CallFirstPage();
            ProcedureAfterCall();
        }

        private void ProcedureAfterCall()
        {
            if (viewReadBasic != null)
                otbData = viewReadBasic.OtbDataToRead;
            viewReadBasic = view.ReadBasic;
            viewReadBasic.OtbDataToRead = otbData;
            viewReadBasic.UpdateViewData();
        }

        public void FirstTime()
        {
            view.CallFirstPage();
            ProcedureAfterCall();
        }
    }
}
